package com.by;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class Applico implements ServletContextListener {

    private ServletContext sc = null;

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("容器关闭初始化");

        sc = servletContextEvent.getServletContext();

        String appName = sc.getServletContextName();

        sc.setAttribute("buildVersion", "1.1");


    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        System.out.println("容器关闭");
    }
}
